#pragma once

#include "ActivityParameterNode.h"

#include "Parameter.h"

namespace uml {

ActivityParameterNode::ActivityParameterNode(const QString& umlType)
    : ObjectNode(umlType) {}

void ActivityParameterNode::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    ObjectNode::fromJson(json, errorList);
    parameter_ = JsonSerializable::create<Parameter>(json.value("parameter"), errorList);

}

void ActivityParameterNode::toJson(QJsonObject& json) {
    ObjectNode::toJson(json);
    if (parameter_) {
        QJsonObject parameter_json;
        parameter_->toJson(parameter_json);
        json.insert("parameter", parameter_json);
    }
}

/// <summary>
/// parameter getter
/// The Parameter for which the ActivityParameterNode will be accepting or providing
/// values.
/// </summary>
shared_ptr<Parameter> ActivityParameterNode::parameter() const {
    return parameter_;
}

/// <summary>
/// parameter setter
/// The Parameter for which the ActivityParameterNode will be accepting or providing
/// values.
/// </summary>
void ActivityParameterNode::setParameter(shared_ptr<Parameter> value) {
    parameter_ = value;
}

} // namespace uml
